package com.spic.business.violation.supervision.speed.service.impl;

import com.spic.business.violation.supervision.speed.domain.VehicleSpeedRecordDTO;
import com.spic.business.violation.supervision.speed.service.IViolationsSpeedRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description 定时获取速度任务
 * @Author AnQi
 * @Date 2021/10/13
 */
@Component("speedInfoTask")
public class SpeedInfoTimeTask {

    @Autowired
    private IViolationsSpeedRecordService recordService;

    @Scheduled(cron = "30 1 * * * ?")
    public List<VehicleSpeedRecordDTO> getSpeed()
    {
        List<VehicleSpeedRecordDTO> dtos= VehicleSpeedRecordDTO.generate();
//        System.out.println(dtos);
        recordService.insertViolationsSpeedRecord(dtos);
        return dtos;
    }
}
